from pydantic import BaseModel
from typing import List, Dict, Any, Optional

class Base64ImageRequest(BaseModel):
    """Request model for base64 image OCR"""
    image_base64: str

class DigitOCRRequest(BaseModel):
    """Request model for digit-only OCR recognition"""
    confidence_threshold: Optional[float] = 0.8  # Higher default for digits
    filter_spaces: Optional[bool] = True
    filter_special_chars: Optional[bool] = True

class OCRRecognizeRequest(BaseModel):
    """Request model for OCR recognition with options"""
    language: Optional[str] = "ch"  # Default to Chinese+English
    use_angle_cls: Optional[bool] = True
    confidence_threshold: Optional[float] = 0.5

class OCRResult(BaseModel):
    """Single OCR result item"""
    text: str
    confidence: float
    bbox: List[List[int]]  # Bounding box coordinates

class OCRData(BaseModel):
    """OCR recognition data"""
    results: List[OCRResult]
    total_text: str
    processing_time: float
    language_used: str
    total_characters: int
    average_confidence: float

class OCRResponse(BaseModel):
    """Standard OCR API response"""
    success: bool
    message: str
    data: Optional[OCRData] = None

class HealthResponse(BaseModel):
    """Health check response"""
    status: str
    message: str
    version: str

class LanguagesResponse(BaseModel):
    """Languages and model information response"""
    success: bool
    message: str
    data: Optional[Dict[str, Any]] = None